#ifndef __SUBSYSTEM_TICK_SHOW_H__
#define __SUBSYSTEM_TICK_SHOW_H__

#include "Subsystems/Subsystem.hpp"
#include <mutex>
#include <map>
#include <cstdint>

namespace ChatLimit
{
    enum class ChatLimitType
    {
        Normal,
        Limit,
        Kick
    };

    class SubsystemChatLimit : public PocketSurvival::Subsystem
    {
    private:
        float m_waitTime = 0;
        std::mutex m_tableMutex;
        std::map<std::string, int32_t> m_chatCountTable;

    public:
        virtual const std::string& getName() const override;

        ChatLimitType addMessageCount(const std::string &username);
        inline void clearMessageCount();

        virtual void update(float dt) override;
        virtual PocketSurvival::SubUpdateType getUpdateType() override;

    public:
        SubsystemChatLimit();
    };

    inline void SubsystemChatLimit::clearMessageCount()
    {
        m_tableMutex.lock();
        m_chatCountTable.clear();
        m_tableMutex.unlock();
    }
}

#endif
